package com.lianxian.xindong.me.mvp.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.library.YLCircleImageView;
import com.hxb.library.base.BaseFragment;
import com.hxb.library.di.component.AppComponent;
import com.hxb.library.utils.AntiShakeUtils;
import com.hxb.library.utils.HxbUtils;
import com.lianxian.xindong.me.R;
import com.lianxian.xindong.me.R2;
import com.lianxian.xindong.me.di.component.DaggerMeComponent;
import com.lianxian.xindong.me.mvp.contract.MeContract;
import com.lianxian.xindong.me.mvp.presenter.MePresenter;
import com.lianxian.xindong.me.mvp.ui.activity.MyInterestActivity;
import com.lianxian.xindong.me.mvp.ui.activity.MyVisitorActivity;
import com.lianxian.xindong.me.mvp.ui.activity.PraiseToMeActivity;
import com.lianxian.xindong.me.mvp.ui.activity.UserDetailActivity;

import butterknife.BindView;
import butterknife.OnClick;

import static com.hxb.library.utils.Preconditions.checkNotNull;


/**
 * @作者：hexingbo
 * @时间：06/30/2023
 * @描述：
 */
public class MeFragment extends BaseFragment<MePresenter> implements MeContract.View {

    @BindView(R2.id.iv_user_head)
    YLCircleImageView ivUserHead;
    @BindView(R2.id.tv_user_nice)
    TextView tvUserNice;
    @BindView(R2.id.iv_user_vip)
    ImageView ivUserVip;
    @BindView(R2.id.iv_user_code2)
    ImageView ivUserCode2;
    @BindView(R2.id.tv_heart)
    TextView tvHeart;
    @BindView(R2.id.tv_user_heart_number)
    TextView tvUserHeartNumber;
    @BindView(R2.id.tv_user_sex_and_age)
    TextView tvUserSexAndAge;
    @BindView(R2.id.tv_blind_date)
    TextView tvBlindDate;
    @BindView(R2.id.tv_user_blind_date_number)
    TextView tvUserBlindDateNumber;
    @BindView(R2.id.iv_next)
    ImageView ivNext;
    @BindView(R2.id.tv_user_number_visitor)
    TextView tvUserNumberVisitor;
    @BindView(R2.id.lv_user_visitor)
    LinearLayout lvUserVisitor;
    @BindView(R2.id.tv_user_number_praise)
    TextView tvUserNumberPraise;
    @BindView(R2.id.lv_user_praise)
    LinearLayout lvUserPraise;
    @BindView(R2.id.tv_user_number_attention)
    TextView tvUserNumberAttention;
    @BindView(R2.id.lv_user_attention)
    LinearLayout lvUserAttention;
    @BindView(R2.id.tv_number_fans)
    TextView tvNumberFans;
    @BindView(R2.id.lv_fans)
    LinearLayout lvFans;

    public static MeFragment newInstance() {
        MeFragment fragment = new MeFragment();
        return fragment;
    }

    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {
        DaggerMeComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_me, container, false);
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

    }

    @Override
    public void setData(@Nullable Object data) {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        HxbUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        HxbUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {

    }

    @OnClick({R2.id.rv_user_info, R2.id.iv_user_code2})
    public void onViewUserInfoClicked(View view) {
        if (AntiShakeUtils.isInvalidClick(view)) {
            return;
        }
        if (view.getId() == R.id.rv_user_info) {
            //用户信息
            launchActivity(new Intent(getContext(), UserDetailActivity.class));
        } else if (view.getId() == R.id.iv_user_code2) {
            //二维码
        }
    }

    @OnClick({R2.id.lv_user_visitor, R2.id.lv_user_praise, R2.id.lv_user_attention, R2.id.lv_fans})
    public void onViewUserTableClicked(View view) {
        if (AntiShakeUtils.isInvalidClick(view)) {
            return;
        }
        if (view.getId() == R.id.lv_user_visitor) {
            //访问量
            launchActivity(new Intent(getContext(), MyVisitorActivity.class));
        } else if (view.getId() == R.id.lv_user_praise) {
            //获赞量
            launchActivity(new Intent(getContext(), PraiseToMeActivity.class));
        } else if (view.getId() == R.id.lv_user_attention) {
            //我的关注
            launchActivity(new Intent(getContext(), MyInterestActivity.class));
        } else if (view.getId() == R.id.lv_fans) {
            //我的粉丝
        }
    }

    @OnClick({R2.id.iv_heart_vip, R2.id.iv_matchmaker_join})
    public void onViewBannerClicked(View view) {
        if (AntiShakeUtils.isInvalidClick(view)) {
            return;
        }
        if (view.getId() == R.id.iv_heart_vip) {
            //心动VIP
        } else if (view.getId() == R.id.iv_matchmaker_join) {
            //招募红娘
        }
    }

    @OnClick({R2.id.tv_me_share, R2.id.tv_me_info, R2.id.tv_me_order,
            R2.id.tv_me_wallet, R2.id.tv_center_service,
            R2.id.tv_blind_date_service, R2.id.tv_centet_safe,
            R2.id.tv_customer_service, R2.id.tv_setting})
    public void onViewOtherItemClicked(View view) {
        if (AntiShakeUtils.isInvalidClick(view)) {
            return;
        }
        if (view.getId() == R.id.tv_me_share) {
            //我的分享
        } else if (view.getId() == R.id.tv_me_info) {
            //我的资料
        } else if (view.getId() == R.id.tv_me_order) {
            //我的订单
        } else if (view.getId() == R.id.tv_me_wallet) {
            //我的钱包
        } else if (view.getId() == R.id.tv_center_service) {
            //服务中心
        } else if (view.getId() == R.id.tv_blind_date_service) {
            //线下相亲服务
        } else if (view.getId() == R.id.tv_centet_safe) {
            //安全中心
        } else if (view.getId() == R.id.tv_customer_service) {
            //联系客服
        } else if (view.getId() == R.id.tv_setting) {
            //设置
        }
    }
}
